Utils = {};

Utils.string = {
		format:function(){
			
		},
		zeroSeat:function(value,count){
			value = ""+value;
			if(value.length < count){
				for(var i=0;i<count - value.length;i++){
					value = "0"+value;
				}
			}
			return value;
		}
};

Utils.proxy = function(func,params){
	return function(){
		func(params);
	};
};

Utils.center = {
		left:function(element){
			var elementWidth = parseInt(element.style.width);
			var offsetWidth = window.document.offsetWidth;
			var left = offsetWidth - (offsetWidth/2+elementWidth/2);
			return left;
		},
		top:function(element){
			var elementHeight = parseInt(element.style.height);
			var offsetHeight = window.document.offsetHeight;
			var top = offsetHeight - (offsetHeight/2+elementHeight/2);
			return top;
		},
		info:function(element){
			return [Utils.center.left(element),Utils.center.top(element)];
		}
};

Utils.math = {
		radians:function(degrees){
			return Math.round(degrees*Math.PI/180);
		},
		degrees:function(radians){
			return Math.round(radians*180/Math.PI);
		}
};

Utils.pixel = {
		number:function(value){
			return Number(value.replace("px",""));
		},
		style:function(value){
			var regex = /.*%$/;
			if(regex.test(value) 
				|| value=="auto"){
				return value;
			}
			return value+"px";
		}
};

Utils.date = {
		//----------------------------------------------------------------------------------------------//当前时间
		now:function(){
			return new Date();
		},
		//----------------------------------------------------------------------------------------------//当前时间毫秒数
		millis:function(){
			return new Date().getTime();
		},
		//----------------------------------------------------------------------------------------------//相差月数
		diffMonth:function(max,min){
			
		},
		//----------------------------------------------------------------------------------------------//相差天数
		diffDate:function(max,min){
			var hours = this.diffHour(max, min);
			
			return Math.floor(hours/24);
		},
		//----------------------------------------------------------------------------------------------//相差小时
		diffHour:function(max,min){
			var minutes = this.diffMinute(max, min);
			
			return Math.floor(minutes/24);
		},
		//----------------------------------------------------------------------------------------------//相差分钟
		diffMinute:function(max,min){
			var seconds = this.diffSecond(max, min);
			
			return Math.floor(seconds/60);
		},
		//----------------------------------------------------------------------------------------------//相差秒数
		diffSecond:function(max,min){
			var milliseconds = this.diffMilliseconds(max, min);
			
			return Math.floor(milliseconds/1000);
		},
		//----------------------------------------------------------------------------------------------//相差毫秒
		diffMilliseconds:function(max,min){
			return max.getTime()-min.getTime();
		},
		//----------------------------------------------------------------------------------------------//剩余时间计算 最大为天
		diff:function(max,min){
			var diffms = this.diffMilliseconds(max, min);
			
			return diff(diffms);
		},
		//----------------------------------------------------------------------------------------------//剩余时间计算 最大为天
		diff:function(diffms){
			var seconds = Math.floor(diffms/1000);
			return	{
				second:seconds%60,
				minute:Math.floor(seconds/60)%60,
				hour:Math.floor(seconds/60/60)%24,
				date:Math.floor(seconds/60/60/24)
			};
		}
};